package base;

import java.util.HashSet;
import java.util.Set;
 class Move {
    private int move1;
    private int move2;

    Move(int m1, int m2) {
        move1 = m1;
        move2 = m2;
    }

    public String toString() {
         return String.valueOf(move1)+" "+String.valueOf(move2);
    }

    public int hashCode() {
        return move1 * 31 + move2 * 31;
    }
    public boolean equals( Object other ) {
        if( this == other ) { return true; }
        if( other instanceof Move ) {
            Move m2 = ( Move ) other;
            return this.move1 == m2.move1 && this.move2 == m2.move2;
        }
        return false;
    }
 }
class Key{
	int i;
	public Key(int i){
		this.i = i;
	}
	public int hashCode() {
		int result = 31;
		return result*i;
	}
	public boolean equals(Object obj){
		if( this == obj ) {
			return true; 
		}
        if( obj instanceof Key ) {
            Key k2 = ( Key ) obj;
            return this.i == k2.i ;
        }
        return false;
	}
}
public class TestHashSet {

	
	public static void main(String[] args) {
		//System.out.println( new Move(2,3).equals( new Move(2,3)));
        //System.out.println( new Move(1,1).hashCode() == new Move(1,1).hashCode()  );
		Set<Key> hashset = new HashSet<Key>();
		Key key1 = new Key(5);
		hashset.add(key1);
		Key key2 = new Key(5);
		hashset.add(key2);
	    System.out.println(hashset.contains(key1));
	    System.out.println(hashset.contains(key2)); 
		

	}

}
